package com.hotel.tv.application.admin.events;

import com.autumn.events.EntityInsertEventListener;
import com.autumn.util.DateUtils;
import com.hotel.tv.entities.Order;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-04-03 12:14
 **/
@Component
public class OrderInsertEventListener implements EntityInsertEventListener<Order, Long> {


    @Override
    public void insertBefore(Object source, Order entity) {
        System.out.println(DateUtils.dateFormat(new Date()) + ":--------------订单[" + entity.getTitle() + "] 插入之前");
    }

    @Override
    public void insertAfter(Object source, Order entity) {
        System.out.println(DateUtils.dateFormat(new Date()) + ":--------------订单[" + entity.getTitle() + "(" + entity.getId() + ")] 插入之后");
    }

    @Override
    public void insertComplete(Object source, Order entity) {
        System.out.println(DateUtils.dateFormat(new Date()) + ":--------------订单[" + entity.getTitle() + "(" + entity.getId() + ")] 提交");
    }

    @Override
    public void insertRollback(Object source, Order entity) {
        System.out.println(DateUtils.dateFormat(new Date()) + ":--------------订单[" + entity.getTitle() + "(" + entity.getId() + ")] 回滚");
    }
}
